<?php 
    session_start();
    include_once 'inc/db.class.php';
    include_once 'inc/function.php';
    //读取banner
    $sqlbanner="select * from banner order by id asc";
    $rsbanner=$db->getData($sqlbanner);
 
    
    //读取新闻
   $sqlnews="select id,title,type from news order by addtime desc";
   $rsnews=$db->getData($sqlnews);
   
   //读取type=1的产品
   $sqlg="select goods.id,goods.name,goods.price,goodspic.pic from goods,goodspic where type=1 and goods.id=gid group by goods.id order by rand() limit 4 ";
   $rsg=$db->getData($sqlg);
   
   $web=getwebinfo();  
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head> 
		<?php include_once 'meta.php'; ?>

		<link href="assets/css/amazeui.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/admin.css" rel="stylesheet" type="text/css" />

		<link href="basic/css/demo.css" rel="stylesheet" type="text/css" />

		<link href="css/hmstyle.css" rel="stylesheet" type="text/css" />
		<script src="http://www.5imoban.net/download/jquery/jquery.1.11.3.js"></script>
		<script src="assets/js/amazeui.min.js"></script>

	</head>

	<body>
		<?php include_once 'header1.php'; ?>
             <b class="line"></b>
			<div class="shopNav">
				<div class="slideall" style="height: auto;">
			        
					  <?php include_once 'header2.php'; ?>
                
			    <div class="bannerTwo">
                      <!--轮播 -->
						<div class="am-slider am-slider-default scoll" data-am-flexslider id="demo-slider-0">
							<ul class="am-slides">
							    <?php foreach ($rsbanner as $v){ ?>
								<li class="banner1"><a target="_blank" href="http://<?php echo $v["url"]; ?>"><img title="<?php echo $v["title"] ?>" src="images/<?php echo $v["name"]; ?>" /></a></li>
								<?php } ?>
							</ul>
						</div>
						<div class="clear"></div>	
						
			    </div>

						<!--侧边导航 -->
						<div id="nav" class="navfull" style="position: static;">
							<div class="area clearfix">
								<div class="category-content" id="guide_2">
									
									<div class="category" style="box-shadow:non e ;margin-top: 2px;height:550px;">
										 <ul class="category-list navTwo" id="js_climit_li">
											<?php foreach (getcategory() as $v){ ?>
											<li>
												<div class="category-info">
													<h3 class="category-name b-category-name"><i><img src="images/<?php echo $v["icon"]; ?>"></i><a href="search.php?id1=<?php echo $v["id"];  ?>&bkey=<?php echo $v["name"];  ?>" class="ml-22" title="<?php echo $v["name"] ?>"><?php echo $v["name"] ?></a></h3>
													<em>&gt;</em></div>
												<div class="menu-item menu-in top">
													<div class="area-in">
														<div class="area-bg">
															<div class="menu-srot">
																<div class="sort-side">
																	<?php foreach (getcategory($v ["id"]) as $v2){ ?>
																	<dl class="dl-sort">
																		<dt><span title="<?php echo $v2["name"]; ?>"><a href="search.php?id2=<?php echo $v2["id"]; ?>&bkey=<?php echo $v["name"];  ?>"><?php echo $v2["name"]; ?></a></span></dt>
																		<?php foreach (getcategory($v2["id"]) as $v3 ){?>
																		<dd><a href="search.php?id3=<?php echo $v3["id"]; ?>" title="<?php echo $v3["name"];  ?>" ><span><?php echo $v3["name"];  ?></span></a></dd>
																		<?php } ?>
																	</dl>
																<?php } ?>
 
																</div>
																<div class="brand-side">
																	<dl class="dl-sort"><dt><span>实力商家</span></dt>
																		<dd><a rel="nofollow" title="呵官方旗舰店" target="_blank" href="#" rel="nofollow"><span  class="red" >呵官方旗舰店</span></a></dd>
																		<dd><a rel="nofollow" title="格瑞旗舰店" target="_blank" href="#" rel="nofollow"><span >格瑞旗舰店</span></a></dd>
																		<dd><a rel="nofollow" title="飞彦大厂直供" target="_blank" href="#" rel="nofollow"><span  class="red" >飞彦大厂直供</span></a></dd>
																		<dd><a rel="nofollow" title="红e·艾菲妮" target="_blank" href="#" rel="nofollow"><span >红e·艾菲妮</span></a></dd>
																		<dd><a rel="nofollow" title="本真旗舰店" target="_blank" href="#" rel="nofollow"><span  class="red" >本真旗舰店</span></a></dd>
																		<dd><a rel="nofollow" title="杭派女装批发网" target="_blank" href="#" rel="nofollow"><span  class="red" >杭派女装批发网</span></a></dd>
																	</dl>
																</div>
															</div>
														</div>
													</div>
												</div>
											<b class="arrow"></b>	
											</li>
											<foeach>
											<?php } ?> 
										
										</ul>
									</div>
								</div>

							</div>
						</div>
						<!--导航 -->
						<script type="text/javascript">
							(function() {
								$('.am-slider').flexslider();
							});
							$(document).ready(function() {
								$("li").hover(function() {
									$(".category-content .category-list li.first .menu-in").css("display", "none");
									$(".category-content .category-list li.first").removeClass("hover");
									$(this).addClass("hover");
									$(this).children("div.menu-in").css("display", "block")
								}, function() {
									$(this).removeClass("hover")
									$(this).children("div.menu-in").css("display", "none")
								});
							})
						</script>


					<!--小导航 -->
					<div class="am-g am-g-fixed smallnav">
						<div class="am-u-sm-3">
							<a href="sort.html"><img src="images/navsmall.jpg" />
								<div class="title">商品分类</div>
							</a>
						</div>
						<div class="am-u-sm-3">
							<a href="#"><img src="images/huismall.jpg" />
								<div class="title">大聚惠</div>
							</a>
						</div>
						<div class="am-u-sm-3">
							<a href="#"><img src="images/mansmall.jpg" />
								<div class="title">个人中心</div>
							</a>
						</div>
						<div class="am-u-sm-3">
							<a href="#"><img src="images/moneysmall.jpg" />
								<div class="title">投资理财</div>
							</a>
						</div>
					</div>

					
				<!--各类活动-->
				<div class="row">
					<li><a><img src="images/row1.jpg"/></a></li>
					<li><a><img src="images/row2.jpg"/></a></li>
					<li><a><img src="images/row3.jpg"/></a></li>
					<li><a><img src="images/row4.jpg"/></a></li>
				</div>
				<div class="clear"></div>	
					<!--走马灯 -->

					<div class="marqueenTwo">
						<span class="marqueen-title"><i class="am-icon-volume-up am-icon-fw"></i>商城头条<em class="am-icon-angle-double-right"></em></span>
						<div class="demo">

							<ul>
							<?php foreach ($rsnews as $v){ ?>
								<li><a target="_blank" href="#"><span>[<?php  echo getnewstype($v["type"]); ?>]</span><?php echo $v["title"]; ?></a></li>
						    <?php }  ?>
							</ul>
                       
						</div>
					</div>
					<div class="clear"></div>
				
				</div>
				
				
							
				<script type="text/javascript">
					if ($(window).width() < 640) {
						function autoScroll(obj) {
							$(obj).find("ul").animate({
								marginTop: "-39px"
							}, 500, function() {
								$(this).css({
									marginTop: "0px"
								}).find("li:first").appendTo(this);
							})
						}
						$(function() {
							setInterval('autoScroll(".demo")', 3000);
						})
					}
				</script>
			</div>
			<div class="shopMainbg">
				<div class="shopMain" id="shopmain">

					<!--热门活动 -->

					<div class="am-container">
					
                     <div class="sale-mt">
		                   <i></i>
		                   <em class="sale-title">限时秒杀</em>
		                   <div class="s-time" id="countdown">
			                    <span class="hh">01</span>
			                    <span class="mm">20</span>
			                    <span class="ss">59</span>
		                   </div>
	                  </div>

					
					  <div class="am-g am-g-fixed sale">
						<?php foreach ($rsg as $v){ ?>
						<div class="am-u-sm-3 sale-item">
							<div class="s-img">
								<a href="introduction.php?id=<?php echo $v["id"]; ?> "><img height="200" src="goodsimg/<?php echo $v["pic"]; ?>" /></a>
							</div>
                           <div class="s-info">
                           	   <a href="introduction.php?id=<?php echo $v["id"]; ?> "><p class="s-title"><?php echo $v["name"]; ?></p></a>
                           	   <div class="s-price">￥<b><?php  echo number_format($v["price"],2); ?></b>
                           	   	  <a class="s-buy" href="introduction.php?id=<?php echo $v["id"]; ?> ">购买</a>
                           	   </div>                          	  
                           </div>								
						</div>
						<?php } ?>
						  
						
					  </div>
                   </div>
					<div class="clear "></div>
           <?php foreach (getcategory() as $v){ 
            //通过该类别ID 一级读取三级产品
            //1 通过一级ID获取所有二级
            $str="";
            foreach(getcategory($v["id"]) as $vv2){
                $vv3=getcategory($vv2["id"]);
                foreach ($vv3 as $vvv3){
                    $str.=$vvv3["id"].",";
                }
            }
            $str=substr($str,0,-1);
            $sqlgoods="select goods.id,goods.name,goods.price,goodspic.pic from goods,goodspic where goods.id=goodspic.gid and goods.cid in(".$str.") group by gid order by rand() limit 7 ";
            $goods=$db->getData($sqlgoods);
            if(count($goods)<7){
                continue;
            }
           ?>
            <div class="f1">
					<!--甜点-->
					
					<div class="am-container " >
						<div class="shopTitle ">
							<h4 class="floor-title"><?php echo $v["name"]; ?></h4>
    							<div class="today-brands " style="right:0px ;top:13px;">
								<?php foreach (getcategory($v["id"]) as $k2=>$v2){ ?>
								<a href="search.php?id2=<?php echo $v2["id"]; ?>&bkey=<?php echo $v2["name"]; ?>"><?php echo $v2["name"]; ?></a>
								    <?php if($k2<count(getcategory($v["id"]))-1){ ?>|<?php } ?>
								<?php } ?>
							</div> 

						</div>
					</div>
					
					<div class="am-g am-g-fixed floodSix ">				
						<div class="am-u-sm-5 am-u-md-3 text-one list">
													
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>">
								<img src="goodsimg/<?php echo $goods[0]["pic"]; ?>" />
								<div class="outer-con ">
									<div class="title ">
										<?php echo $goods[0]["name"]; ?>
									</div>
									<div class="sub-title ">
										￥<?php echo number_format($goods[0]["price"],2); ?>
									</div>
								</div>
							</a>
							<div class="triangle-topright"></div>	
						</div>
						
						<div class="am-u-sm-7 am-u-md-5 am-u-lg-2 text-two big">
							
								<div class="outer-con ">
									<div class="title ">
										<?php echo $goods[1]["name"]; ?>
									</div>
									<div class="sub-title ">
										￥<?php echo number_format($goods[1]["price"],2); ?>
									</div>
									
								</div>
								<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[1]["pic"]; ?>" /></a>						
						</div>

						<li>
						<div class="am-u-md-2 am-u-lg-2 text-three">
							<div class="boxLi"></div>
							<div class="outer-con ">
								<div class="title ">
									<?php echo $goods[2]["name"]; ?>
								</div>								
								<div class="sub-title ">
									¥<?php echo number_format($goods[2]["price"],2); ?>
								</div>
								
							</div>
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[2]["pic"]; ?>" /></a>
						</div>
						</li>
						<li>
						<div class="am-u-md-2 am-u-lg-2 text-three sug">
							<div class="boxLi"></div>
							<div class="outer-con ">
								<div class="title ">
									<?php echo $goods[3]["name"]; ?>
								</div>
								<div class="sub-title ">
									¥<?php echo number_format($goods[3]["price"],2); ?>
								</div>
								
							</div>
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[3]["pic"]; ?>" /></a>
						</div>
						</li>
						<li>
						<div class="am-u-sm-4 am-u-md-5 am-u-lg-4 text-five">
							<div class="boxLi"></div>
							<div class="outer-con ">
								<div class="title ">
									<?php echo $goods[4]["name"]; ?>
								</div>								
								<div class="sub-title ">
									¥<?php echo number_format($goods[4]["price"],2); ?>
								</div>
								
							</div>
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[4]["pic"]; ?>" /></a>
						</div>	
						</li>
						<li>
						<div class="am-u-sm-4 am-u-md-2 am-u-lg-2 text-six">
							<div class="boxLi"></div>
							<div class="outer-con ">
								<div class="title ">
									<?php echo $goods[5]["name"]; ?>
								</div>
								<div class="sub-title ">
									¥<?php echo number_format($goods[5]["price"],2); ?>
								</div>
								
							</div>
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[5]["pic"]; ?>" /></a>
						</div>	
						</li>
						<li>
						<div class="am-u-sm-4 am-u-md-2 am-u-lg-4 text-six">
							<div class="boxLi"></div>
							<div class="outer-con ">
								<div class="title ">
									<?php echo $goods[6]["name"]; ?>
								</div>
								<div class="sub-title ">
									¥<?php echo number_format($goods[6]["price"],2); ?>
								</div>
								
							</div>
							<a href="introduction.php?id=<?php echo $goods[0]["id"];  ?>"><img src="goodsimg/<?php echo $goods[6  ]["pic"]; ?>" /></a>
						</div>	
						</li>						
					</div>

					<div class="clear "></div>
            </div>
            <?php }  ?>
					<?php include_once 'footer.php'; ?>
			</div>
		</div>
		</div>

		<!--引导 -->
		<div class="navCir">
			<li class="active"><a href="home2.html"><i class="am-icon-home "></i>首页</a></li>
			<li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
			<li><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>	
			<li><a href="person/index.html"><i class="am-icon-user"></i>我的</a></li>					
		</div>
		<!--菜单 -->
		<?php include_once 'aside.php'; ?>
		<script>
			window.jQuery || document.write('<script src="basic/js/jquery.min.js "><\/script>');
		</script>
		<script type="text/javascript " src="basic/js/quick_links.js "></script>
	</body>

</html>